package com.ycfmedical.bed.present;

import com.ycfmedical.bed.Constants;
import com.ycfmedical.bed.R;
import com.ycfmedical.bed.bean.TextContent;
import com.ycfmedical.bed.local.DataManager;
import com.ycfmedical.bed.local.entity.User;
import com.ycfmedical.bed.ui.fragment.UserInfoFragment;

import java.util.ArrayList;
import java.util.List;

import cn.droidlover.xdroidmvp.mvp.XPresent;

/**
 * Created by Administrator on 2017/2/24 0024.
 */
public class UserInfoPresenter extends XPresent<UserInfoFragment> {

    private List<String> datas = new ArrayList<>();
    private List<TextContent> textcontentList = new ArrayList<>();


    public void loadData() {
        User user = DataManager.getInstance().getUser();
        setUserContent(user,textcontentList);
     //   setTexts(user,datas);
     //   showUserInfo(datas);


    }

    private void setUserContent(User user, List<TextContent> textcontentList) {
        if (user == null) {
            getV().getvDelegate().toastShort("用户为空");
            return;
        }
        if(null==user.getSex()||user.getSex().equals("女")||user.getSex().equals("")){
            getV().isGirl(true);
        }else if(user.getSex().equals("男")){
            getV().isGirl(false);
        }

        textcontentList.add(new TextContent(Constants.USER_NAME, user.getName() + "", R.drawable.name_icon));
        textcontentList.add(new TextContent(Constants.DOCTOR_NAME, user.getDoctorName() + "", -1));
        textcontentList.add(new TextContent(Constants.SEX, user.getSex() + "", R.drawable.sex_icon));
        textcontentList.add(new TextContent(Constants.NURSE_NAME, user.getNurseName() + "" + "", -1));
        textcontentList.add(new TextContent(Constants.AGE, user.getAge() + "", R.drawable.age_icon));
        textcontentList.add(new TextContent(Constants.TREAMENT_ARRANGE, user.getTreatmentArrange() + "", -1));
        textcontentList.add(new TextContent(Constants.HEIGHT, user.getHeight() + "cm", R.drawable.hight_icon));
        textcontentList.add(new TextContent(Constants.USER_PHONE, user.getUserPhone() + "", -1));
        textcontentList.add(new TextContent(Constants.GUOMIN_HISTORY, user.getAllergicHistory() + "", -1));
        textcontentList.add(new TextContent(Constants.EMERGENT_PHONE, user.getEnmergenPhone() + "", -1));
        textcontentList.add(new TextContent(Constants.DISEASE, user.getDisease() + "", -1));
        textcontentList.add(new TextContent(Constants.SYMPTOM, user.getSymptom() + "", -1));
        textcontentList.add(new TextContent(Constants.TREATMENT, user.getTreatment() + "", -1));
        textcontentList.add(new TextContent(Constants.COUNT_BAlANCE, user.getCountBalance() + "", -1));

        getV().showData(textcontentList);
    }

    private void showUserInfo(final List<String> texts) {
//        for (String str : texts) {
//            TextContent textContent = new TextContent();
//            textContent.setTextContent(str);
//            textcontentList.add(textContent);
//        }


    }





    private void setTexts(User userInfo, List<String> texts) {
        //12条信息
        texts.add(Constants.USER_NAME +" : "+ userInfo.getAge());
        texts.add(Constants.SEX +" : "+ userInfo.getAge());
        texts.add(Constants.AGE +" : "+ userInfo.getAge());
        texts.add(Constants.DOCTOR_NAME + " : "+userInfo.getDoctorName());
        texts.add(Constants.GUOMIN_HISTORY + " : "+userInfo.getAllergicHistory());
        texts.add(Constants.NURSE_NAME +" : "+ userInfo.getNurseName());
        texts.add(Constants.HEIGHT +" : "+ userInfo.getHeight()+"cm");
        texts.add(Constants.TREAMENT_ARRANGE +" : "+ userInfo.getTreatmentArrange());
        texts.add(Constants.DISEASE + " : "+userInfo.getDisease());
        texts.add(Constants.USER_PHONE + " : "+userInfo.getUserPhone());
        texts.add(Constants.SYMPTOM + " : "+userInfo.getSymptom());
        texts.add(Constants.COUNT_BAlANCE + " : "+userInfo.getCountBalance());
        texts.add(Constants.TREATMENT +" : "+ userInfo.getTreatment());
        texts.add(Constants.EMERGENT_PHONE + " : "+userInfo.getEnmergenPhone());

    }



}
